﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhsystem.Main;
using dhSystemBLL.orderData;
using baseSet.importExport;
using dhDataAcess.dataAcess;
using dhDataAcess.dataAcess .orderDataSetTableAdapters ;
using FastReport;
using dhDataAcess.baseBLL;
using System.Data.SqlClient;
using baseSet.power;
namespace dhsystem.orderForm
{
    public partial class FrmPbomMaster : Form
    {
        pbomDetailBLL pbomDetail = new pbomDetailBLL();
        pbomMasterBLL pbomMaster = new pbomMasterBLL();
        pbomMarkBLL pbomMark = new pbomMarkBLL();
        materialListBLL materilList = new materialListBLL();
        string state;
        public FrmPbomMaster()
        {
            InitializeComponent();
        }
        //新增按钮，显示新增数据组件
        private void toolAdd_Click(object sender, EventArgs e)
        {
            state = "新增";
            FrmPbomMasterAdd pbomMasterAdd = new FrmPbomMasterAdd(bindingSourcePbomMaster  ,state,"" );
            pbomMasterAdd.ShowDialog();
        }
 
        //工具栏查询按钮，查询所有列表数据
        private void toolQuery_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.pbomMaster );
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridPbomMaster.DataSource = query.rTable;
            }
        }
        //工具栏的编辑按钮,修改数据
        private void toolEdit_Click(object sender, EventArgs e)
        {
            string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            state = "编辑";
            FrmPbomMasterAdd pbomMasterAdd = new FrmPbomMasterAdd(bindingSourcePbomMaster, state, pname);
            pbomMasterAdd.ShowDialog();
        }
        //删除按钮，删除选中行数据
        private void toolDel_Click(object sender, EventArgs e)
        {
            string pname = dGridPbomMaster.Rows[dGridPbomMaster.CurrentRow.Index].Cells[1].Value.ToString();
            try
            {
                DialogResult result = MessageBox.Show("是否删除：" + pname + "！", "提示信息", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {

                    bindingSourcePbomMaster.DataSource = pbomMaster.pbomMasterDel(pname);
                   
                }
                getData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

        }
        //查询按钮，按条件查询数据
        private void buttonQuery_Click(object sender, EventArgs e)
        {
            try
            {
               
                bindingSourcePbomMaster .DataSource =pbomMaster .getpbomMasterAllBylikepname  ("%" + textPnameQuery .Text  + "%");
                dGridPbomMaster.DataSource = bindingSourcePbomMaster;
                DcolumnSet.colSet(moduleInfo.pbomMaster, dGridPbomMaster);
                toolStripStatusLabel1.Text = "Bom主表数据总条数:" + dGridPbomMaster.RowCount.ToString() + "条";

                bindingSourcepbomDetail.DataSource = pbomDetail.getpbomDetailAllBypnamelike("%" + textPnameQuery.Text + "%");
                //bindingSourcepbomDetail.DataMember = "fk_pbomDetailpname";
                dGridpboDetail.DataSource = bindingSourcepbomDetail;
                DcolumnSet.colSet(moduleInfo.pbomDetail, dGridpboDetail);
                toolStripStatusLabel3.Text = "Bom从表数据总条数:" + dGridpboDetail.RowCount.ToString() + "条";

                bindingSourcepbomMark.DataSource = pbomMark.getpbomMarkAllBypnamelike("%" + textPnameQuery.Text + "%");
                //bindingSourcepbomMark.DataMember = "fk_pbomMark_pname";
                dGridpbomMark.DataSource = bindingSourcepbomMark;
                DcolumnSet.colSet(moduleInfo.pbomMark, dGridpbomMark);
                toolStripStatusLabel5.Text = "Bom参数表数据总条数:" + dGridpbomMark.RowCount.ToString() + "条";
              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        //刷新按钮
        private void buttupdate_Click(object sender, EventArgs e)
        {
            getData();

        }
        //工具栏退出按钮，退出窗口
        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //打开窗口时显示列表数据
        private void FrmPbomMaster_Load_1(object sender, EventArgs e)
        {
            getData();
        }



        private void getData()
        {
            pbomDetailTableAdapter pbomDetailAdapter = new pbomDetailTableAdapter();  //bom明细表
            pbomMasterTableAdapter pbomMasterAdapter = new pbomMasterTableAdapter();
            pbomMarkTableAdapter pboMarkAdapter = new pbomMarkTableAdapter();
            orderDataSet pbom = new orderDataSet();
            pbomDetailAdapter.FillpbomDetailAll(pbom.pbomDetail);
            pbomMasterAdapter.FillpbomMasterAll(pbom.pbomMaster);
            pboMarkAdapter.FillpbomMarkALL(pbom.pbomMark); 
            bindingSourcePbomMaster.DataSource = pbom;
            bindingSourcePbomMaster.DataMember = "pbomMaster";
            dGridPbomMaster.DataSource = bindingSourcePbomMaster;

            DcolumnSet.colSet(moduleInfo.pbomMaster, dGridPbomMaster);
            toolStripStatusLabel1.Text = "Bom主表数据总条数:" + dGridPbomMaster.RowCount.ToString() + "条";

            bindingSourcepbomDetail.DataSource = bindingSourcePbomMaster;
            bindingSourcepbomDetail.DataMember = "fk_pbomDetailpname";
            dGridpboDetail.DataSource = bindingSourcepbomDetail;
            DcolumnSet.colSet(moduleInfo.pbomDetail, dGridpboDetail);
            toolStripStatusLabel3.Text = "Bom从表数据总条数:" + dGridpboDetail.RowCount.ToString() + "条";

            bindingSourcepbomMark.DataSource = bindingSourcePbomMaster;
            bindingSourcepbomMark.DataMember = "fk_pbomMark_pname";
           dGridpbomMark .DataSource   = bindingSourcepbomMark ;
            DcolumnSet.colSet(moduleInfo.pbomMark , dGridpbomMark  );
           toolStripStatusLabel5 .Text  = "Bom参数表数据总条数:" + dGridpbomMark.RowCount.ToString() + "条";


           sysDataSet.modulAaccessDataTable modulAaccess = powerSet.modulPower(moduleInfo.pbomMaster );
           foreach (sysDataSet.modulAaccessRow modulAaccessRow in modulAaccess)
           {
               buttonQuery.Enabled = modulAaccessRow.showAc;
               toolAdd.Enabled = modulAaccessRow.addAc;
               toolEdit.Enabled = modulAaccessRow.editAc;
               toolDel.Enabled = modulAaccessRow.delAc;
               toolPrint.Enabled = modulAaccessRow.printAc;
               toolExport.Enabled = modulAaccessRow.exportAc;
              // buttImport.Enabled = modulAaccessRow.importAc;

           }
        }

        private void bindingSourcepbomDetail_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void toolPrint_Click(object sender, EventArgs e)
        {

            string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            Report r = new Report();
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            dt.Load(basicSql.getpbomaster(pname));
            ds.Tables.Add(dt);
            r.Load(@"E:\东华软件项目\报表\pbomaster.frx");
            //r.Load(@"\\192.168.0.27\东华软件\报表\piaoranorder.frx");
            r.RegisterData(ds);
            r.Design();
        }

            #region 无用的代码
            //Report r = new Report();
            //DataSet ds = new DataSet();
            //DataSetPrint.bomMasterDataTable masterTable=new DataSetPrint.bomMasterDataTable();
            //DataSetPrint.bodDetailDataTable detailTable=new DataSetPrint.bodDetailDataTable();

            //DataSetPrint.bomMasterRow masterRow = masterTable.NewbomMasterRow();
            //masterRow.title = "东华（番禺）织造有限公司";
            //masterRow.title2 = "织机技术资料";
            //masterRow.zbDate = DateTime.Now.ToShortDateString();
            //masterRow.pnmae = "KL16696/10M";
            //masterTable.AddbomMasterRow(masterRow);



            //for (int i = 1; i <= 2; i++)
            //{
            //    DataSetPrint.bodDetailRow detailRow = detailTable.NewbodDetailRow();
            //    detailRow.wb = i.ToString();
            //    detailRow.matNum = "数据库值";
            //    detailRow.zlqm = "264";
            //    detailTable.Rows.Add(detailRow);

            //}

            //string zlqm = "0";
            //for (int i = 1; i <= 3; i++)
            //{
            //    DataSetPrint.bodDetailRow detailRow = detailTable.NewbodDetailRow();
            //    detailRow.wb = i.ToString();
            //    detailRow.matNum = "数据库值";
            //    if (zlqm == "0")
            //    {
            //        detailRow.zlqm = "";
            //    }
            //    detailTable.Rows.Add(detailRow);

            //}
            //DataSetPrint.bodDetailRow detailRow1 = detailTable.NewbodDetailRow();
            //detailRow1.wb ="6";
            //detailRow1.matNum = "";
            //detailTable.Rows.Add(detailRow1);

            //DataSetPrint.bodDetailRow detailRow2 = detailTable.NewbodDetailRow();
            //detailRow2.wb = "";
            //detailRow2.matNum = "";
            //detailTable.Rows.Add(detailRow2);

            //DataSetPrint.bodDetailRow detailRow3 = detailTable.NewbodDetailRow();
            //detailRow3.wb = "根芯";
            //detailRow3.matNum = "840#拉架";
            //detailTable.Rows.Add(detailRow3);

            //ds.Tables.Add(masterTable);
            //ds.Tables.Add(detailTable);
            //r.RegisterData(ds);
            //r.Load(@"e:\bomReport.frx");
            //r.Design();
            #endregion
       

        private void toolSet_Click(object sender, EventArgs e)
        {
            Report r = new Report();
            DataSet ds = new DataSet();
            dhSystemBLL.basicData.basListBLL basic=new dhSystemBLL.basicData.basListBLL();

            sysDataSet.basListDataTable basicTable = basic.getbasListAll();

            DataSetPrint.basicPrintTableDataTable bPrint = new DataSetPrint.basicPrintTableDataTable();
            int i = 1;
            foreach (sysDataSet.basListRow row in basicTable)
            {
                DataSetPrint.basicPrintTableRow insertRow = bPrint.NewbasicPrintTableRow();
                if (row.basNum == "07") insertRow.basNum = "";
                else insertRow.basNum = row.basNum;
                insertRow.basType=row.basType;
                
                bPrint.AddbasicPrintTableRow(insertRow);
                //if (i %  2 == 0)
                //{
                //    DataSetPrint.basicPrintTableRow insertRow1 = bPrint.NewbasicPrintTableRow();
                //    insertRow1.basType ="两行分隔线";
                //    insertRow.basNum = "";
                //    bPrint.AddbasicPrintTableRow(insertRow1);
                //}
                i++;
            }


            ds.Tables.Add(bPrint);
            r.Load(@"e:\basic.frx");
            r.RegisterData(ds);
            r.Design();
        }

        private void toolExport_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.pbomMaster , dGridPbomMaster , "工艺表信息");
            frm.ShowDialog();
        }
       
        private void 梳织打印ToolStripMenuItem_Click(object sender, EventArgs e)
       {
          string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
          //  DataSetPrint.pbomTableDataTable pbomTable = new DataSetPrint.pbomTableDataTable();
          //  DataSetPrint.pbomDtailTableDataTable pbomDtailTable = new DataSetPrint.pbomDtailTableDataTable();
          //  DataSetPrint.pbomMarkDataTable pbomMarkTable = new DataSetPrint.pbomMarkDataTable();
          //  DataSetPrint.materialListTableDataTable materialListTable= new DataSetPrint.materialListTableDataTable();
          //  //string matNum = dGridPbomMaster.CurrentRow.Cells["matNum"].Value.ToString();
          //string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
          //orderDataSet.pbomDetailDataTable pbomDetailTable = pbomDetail.getpbomDetailbypanmeAll(pname);
          //orderDataSet.pbomMarkDataTable pbomMarkTable2 = pbomMark.getpbomMarkAllBypname(pname);
          //orderDataSet.pbomMasterDataTable pbomMasterTable = pbomMaster.getpbomMasterAllBypname(pname);
          //orderDataSet.materialListDataTable material = materilList.getmaterialListAll  () ;
    
#region 旧代码          foreach (orderDataSet.pbomMasterRow pbomMasterRow in pbomMasterTable)

#endregion          }
   


            Report r = new Report();
            DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            //dt.Load(basicSql.getpbomaster(pname));
             ViewDataSet.V_pboMasterDataTable V_PbomTable =pbomMaster .getV_pboMasterAllBypname (pname ) ;
            DataSetPrint.pbomTable1DataTable  pbomTable = new DataSetPrint.pbomTable1DataTable() ;
          foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
           {
               DataSetPrint .pbomTable1Row pbomRow =pbomTable.NewpbomTable1Row ();
               if (!V_pbomRow.IsmatSpecNull())
               {
                   pbomRow.matSpec = V_pbomRow.matSpec;
               }
               else { pbomRow.matSpec = ""; }
               if (!V_pbomRow.IsmatNameNull())
               {
                   pbomRow.matName = V_pbomRow.matName;
               }
               else { pbomRow.matName = ""; }
               pbomRow.pname = V_pbomRow.pname;
               if (!V_pbomRow.IscustNumNull())
               {
                   pbomRow.custNum = V_pbomRow.custNum;
               }
               else { pbomRow.custNum = ""; }
               if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
               else { pbomRow.aweight = ""; }
               if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
               else { pbomRow.bweight = ""; }
               if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
               else { pbomRow.awgight = ""; }
               pbomRow.createDate = V_pbomRow.createDate.ToString();
               if (!pbomRow.IscreateUserNull())
               {
                   pbomRow.createUser = pbomRow.createUser;
               }
               else { pbomRow.createUser = ""; }
               if (!V_pbomRow.IswbNull ())
               {
                   pbomRow.wb = V_pbomRow.wb;
               }
               else { pbomRow.wb = ""; }
               if (V_pbomRow.matNum !="0")
               {
                   pbomRow.matNum = V_pbomRow.matNum;
               }
               else { pbomRow.matNum = ""; }
               if (!V_pbomRow.IsptNull ())
               {
                   pbomRow.pt = V_pbomRow.pt;
               }
               else { pbomRow.pt = ""; }
               if (!V_pbomRow.IspzNull ())
               {
                   pbomRow.pz = V_pbomRow.pz;
               }
               else { pbomRow.pz = ""; }
               if (!V_pbomRow.IscustNameNull ())
               {
                   pbomRow.custName = V_pbomRow.custName;
               }
               else { pbomRow.custName = ""; }
               if (V_pbomRow.alen != 0)
               {
                   pbomRow.alen = V_pbomRow.alen.ToString();
               }
               else { pbomRow.alen = ""; }
               pbomRow.aweight = V_pbomRow.aweight.ToString();
               if (V_pbomRow.ts != 0)
               {
                   pbomRow.ts = V_pbomRow.ts.ToString();
               }
               else { pbomRow.ts = ""; }
               if (V_pbomRow.blen != 0)
               {
                   pbomRow.blen = V_pbomRow.blen.ToString();
               }
               else { pbomRow.blen = ""; }
               if (V_pbomRow.aweight != 0)
               {
                   pbomRow.aweight = V_pbomRow.aweight.ToString();
               }
               else { pbomRow.aweight = ""; }
               if (V_pbomRow.pweight != 0)
               {
                   pbomRow.pweight = V_pbomRow.pweight.ToString();
               }
               else { pbomRow.pweight = ""; }
               if (!pbomRow.IsmarkNull ())
               {
                   pbomRow.mark = V_pbomRow.mark;
               }
               else { pbomRow.mark = ""; }
               if (!V_pbomRow.IsrequestNull())
               {
                   pbomRow.request = V_pbomRow.request;
               }
               else { pbomRow.request = ""; }
               if (!V_pbomRow.IsdifficultyNull())
               {
                   pbomRow.difficulty = V_pbomRow.difficulty;
               }
               else { pbomRow.difficulty = ""; }
               if (!V_pbomRow.IsendopenNull())
               {
                   pbomRow.endopen = V_pbomRow.endopen;
               }
               else { pbomRow.endopen = ""; }
               if (!V_pbomRow.IsendshrinkNull())
               {
                   pbomRow.endshrink = V_pbomRow.endshrink;
               }
               else { pbomRow.endshrink = ""; }
               if (!V_pbomRow.IsgqDensityNull())
               {
                   pbomRow.gqDensity = V_pbomRow.gqDensity;
               }
               else { pbomRow.gqDensity = ""; }
               if (!V_pbomRow.IsmethodsNull())
               {
                   pbomRow.methods = V_pbomRow.methods;
               }
               else { pbomRow.methods = ""; }
               if (!V_pbomRow.IsnumberKfNull())
               {
                   pbomRow.numberKf = V_pbomRow.numberKf;
               }
               else { pbomRow.numberKf = ""; }
               if (!V_pbomRow.IsnumberKfNull())
               {
                   pbomRow.numberNf = V_pbomRow.numberNf;
               }
               else { pbomRow.numberNf = ""; }

               if (!V_pbomRow.IsproductionKfNull())
               {
                   pbomRow.productionKf = V_pbomRow.productionKf;
               }
               else { pbomRow.productionKf = 0;}
               if (!V_pbomRow.IsproductionNfNull())
               {
                   pbomRow.productionNf = V_pbomRow.productionNf;
               }
               else { pbomRow.productionNf = 0; }
               if (!V_pbomRow.IsspeedKfNull())
               {
                   pbomRow.speedKf = V_pbomRow.speedKf;
               }
               else { pbomRow.speedKf = ""; }
               if (!V_pbomRow.IsspeedNfNull())
               {
                   pbomRow.speedNf = V_pbomRow.speedNf;
               }
               else { pbomRow.speedNf = ""; }
               if (!V_pbomRow.IsstartopenNull())
               {
                   pbomRow.startopen = V_pbomRow.startopen;
               }
               else { pbomRow.startopen = ""; }
               if (!V_pbomRow.IsstartshrinkNull())
               {
                   pbomRow.startshrink = V_pbomRow.startshrink;
               }
               else { pbomRow.startshrink = ""; }
               if (!V_pbomRow.IsstartwidthNull())
               {
                   pbomRow.startwidth = V_pbomRow.startwidth;
               }
               else { pbomRow.startwidth = ""; }
               if (!V_pbomRow.IsendwidthNull  ())
               {
                   pbomRow.endwidth  = V_pbomRow.endwidth ;
               }
               else { pbomRow.endwidth = ""; }
               if (!V_pbomRow.IstwoLengthNull())
               {
                   pbomRow.twoLength = V_pbomRow.twoLength;
               }
               else { pbomRow.twoLength = ""; }
               if (!V_pbomRow.IszwDensityNull())
               {
                   pbomRow.zwDensity = V_pbomRow.zwDensity;
               }
               else { pbomRow.zwDensity = ""; }
               if (!V_pbomRow.IszzbasicspecNull())
               {
                   pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
               }
               else { pbomRow.zzbasicspec = ""; }
               if (!V_pbomRow.IszzdifficultyNull())
               {
                   pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
               }
               else { pbomRow.zzdifficulty = ""; }
               if (!V_pbomRow.IszzmachineqtyNull())
               {
                   pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
               }
               else { pbomRow.zzmachineqty = ""; }
               if (!V_pbomRow.IszzproduceqtyNull())
               {
                   pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
               }
               else { pbomRow.zzproduceqty = ""; }
               if (!V_pbomRow.IszzproductionNull())
               {
                   pbomRow.zzproduction = V_pbomRow.zzproduction;
               }
               else { pbomRow.zzproduction = ""; }
               if (!pbomRow.IszzrequestNull())
               {
                   pbomRow.zzrequest = V_pbomRow.zzrequest;
               }
               else { pbomRow.zzrequest = ""; }
               if (!V_pbomRow.IszzspeedNull())
               {
                   pbomRow.zzspeed = V_pbomRow.zzspeed;
               }
               else { pbomRow.zzspeed = ""; }
               if (!V_pbomRow.IszzyujiproductionNull())
               {
                   pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
               }
               else { pbomRow.zzyujiproduction = ""; }
               if (!V_pbomRow.IszzzwDensityNull())
               {
                   pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
               }
               else { pbomRow.zzzwDensity = ""; }
               if (!V_pbomRow.IszzzwjgtxNull())
               {
                   pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
               }
               else { pbomRow.zzzwjgtx = ""; }
               pbomTable.AddpbomTable1Row (pbomRow);

         }
            //ds.Tables.Add (pbomTable);
            //ds.Tables.Add(pbomDtailTable);
            //ds.Tables.Add(pbomMarkTable);
            ds.Tables.Add(pbomTable);
            //r.Load(@"E:\东华软件项目\报表\pbomaster.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\pbomaster.frx");
            r.RegisterData(ds);
            r.Show();
         //r.Design();

        }
        

        private void zhenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            Report r = new Report();
            DataSet ds = new DataSet();
           // DataTable dt = new DataTable();
           // dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable =pbomMaster .getV_pboMasterAllBypname (pname ) ;
            DataSetPrint.pbomTable1DataTable  pbomTable = new DataSetPrint.pbomTable1DataTable() ;
           foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable )
           {
                DataSetPrint .pbomTable1Row pbomRow =pbomTable.NewpbomTable1Row ();
               if (!V_pbomRow.IsmatSpecNull())
               {
                   pbomRow.matSpec = V_pbomRow.matSpec;
               }
               else { pbomRow.matSpec = ""; }
               if (!V_pbomRow.IsmatNameNull())
               {
                   pbomRow.matName = V_pbomRow.matName;
               }
               else { pbomRow.matName = ""; }
               pbomRow.pname = V_pbomRow.pname;
               if (!V_pbomRow.IscustNumNull())
               {
                   pbomRow.custNum = V_pbomRow.custNum;
               }
               else { pbomRow.custNum = ""; }
               if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
               else { pbomRow.aweight = ""; }
               if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
               else { pbomRow.bweight = ""; }
               if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
               else { pbomRow.awgight = ""; }
               pbomRow.createDate = V_pbomRow.createDate.ToString();
               if (!pbomRow.IscreateUserNull())
               {
                   pbomRow.createUser = pbomRow.createUser;
               }
               else { pbomRow.createUser = ""; }
               if (!V_pbomRow.IswbNull ())
               {
                   pbomRow.wb = V_pbomRow.wb;
               }
               else { pbomRow.wb = ""; }
               if (V_pbomRow.matNum !="0")
               {
                   pbomRow.matNum = V_pbomRow.matNum;
               }
               else { pbomRow.matNum = ""; }
               if (!V_pbomRow.IsptNull ())
               {
                   pbomRow.pt = V_pbomRow.pt;
               }
               else { pbomRow.pt = ""; }
               if (!V_pbomRow.IspzNull ())
               {
                   pbomRow.pz = V_pbomRow.pz;
               }
               else { pbomRow.pz = ""; }
               if (!V_pbomRow.IscustNameNull ())
               {
                   pbomRow.custName = V_pbomRow.custName;
               }
               else { pbomRow.custName = ""; }
               if (V_pbomRow.alen != 0)
               {
                   pbomRow.alen = V_pbomRow.alen.ToString();
               }
               else { pbomRow.alen = ""; }
               pbomRow.aweight = V_pbomRow.aweight.ToString();
               if (V_pbomRow.ts != 0)
               {
                   pbomRow.ts = V_pbomRow.ts.ToString();
               }
               else { pbomRow.ts = ""; }
               if (V_pbomRow.blen != 0)
               {
                   pbomRow.blen = V_pbomRow.blen.ToString();
               }
               else { pbomRow.blen = ""; }
               if (V_pbomRow.aweight != 0)
               {
                   pbomRow.aweight = V_pbomRow.aweight.ToString();
               }
               else { pbomRow.aweight = ""; }
               if (V_pbomRow.pweight != 0)
               {
                   pbomRow.pweight = V_pbomRow.pweight.ToString();
               }
               else { pbomRow.pweight = ""; }
               if (!pbomRow.IsmarkNull ())
               {
                   pbomRow.mark = V_pbomRow.mark;
               }
               else { pbomRow.mark = ""; }
               if (!V_pbomRow.IsrequestNull())
               {
                   pbomRow.request = V_pbomRow.request;
               }
               else { pbomRow.request = ""; }
               if (!V_pbomRow.IsdifficultyNull())
               {
                   pbomRow.difficulty = V_pbomRow.difficulty;
               }
               else { pbomRow.difficulty = ""; }
               if (!V_pbomRow.IsendopenNull())
               {
                   pbomRow.endopen = V_pbomRow.endopen;
               }
               else { pbomRow.endopen = ""; }
               if (!V_pbomRow.IsendshrinkNull())
               {
                   pbomRow.endshrink = V_pbomRow.endshrink;
               }
               else { pbomRow.endshrink = ""; }
               if (!V_pbomRow.IsgqDensityNull())
               {
                   pbomRow.gqDensity = V_pbomRow.gqDensity;
               }
               else { pbomRow.gqDensity = ""; }
               if (!V_pbomRow.IsmethodsNull())
               {
                   pbomRow.methods = V_pbomRow.methods;
               }
               else { pbomRow.methods = ""; }
               if (!V_pbomRow.IsnumberKfNull())
               {
                   pbomRow.numberKf = V_pbomRow.numberKf;
               }
               else { pbomRow.numberKf = ""; }
               if (!V_pbomRow.IsnumberKfNull())
               {
                   pbomRow.numberNf = V_pbomRow.numberNf;
               }
               else { pbomRow.numberNf = ""; }

               if (!V_pbomRow.IsproductionKfNull())
               {
                   pbomRow.productionKf = V_pbomRow.productionKf;
               }
               else { pbomRow.productionKf = 0; }
               if (!V_pbomRow.IsproductionNfNull())
               {
                   pbomRow.productionNf = V_pbomRow.productionNf;
               }
               else { pbomRow.productionNf = 0; }
               if (!V_pbomRow.IsspeedKfNull())
               {
                   pbomRow.speedKf = V_pbomRow.speedKf;
               }
               else { pbomRow.speedKf = ""; }
               if (!V_pbomRow.IsspeedNfNull())
               {
                   pbomRow.speedNf = V_pbomRow.speedNf;
               }
               else { pbomRow.speedNf = ""; }
               if (!V_pbomRow.IsstartopenNull())
               {
                   pbomRow.startopen = V_pbomRow.startopen;
               }
               else { pbomRow.startopen = ""; }
               if (!V_pbomRow.IsstartshrinkNull())
               {
                   pbomRow.startshrink = V_pbomRow.startshrink;
               }
               else { pbomRow.startshrink = ""; }
               if (!V_pbomRow.IsstartwidthNull())
               {
                   pbomRow.startwidth = V_pbomRow.startwidth;
               }
               else { pbomRow.startwidth = ""; }
               if (!V_pbomRow.IsendwidthNull  ())
               {
                   pbomRow.endwidth  = V_pbomRow.endwidth ;
               }
               else { pbomRow.endwidth = ""; }
               if (!V_pbomRow.IstwoLengthNull())
               {
                   pbomRow.twoLength = V_pbomRow.twoLength;
               }
               else { pbomRow.twoLength = ""; }
               if (!V_pbomRow.IszwDensityNull())
               {
                   pbomRow.zwDensity = V_pbomRow.zwDensity;
               }
               else { pbomRow.zwDensity = ""; }
               if (!V_pbomRow.IszzbasicspecNull())
               {
                   pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
               }
               else { pbomRow.zzbasicspec = ""; }
               if (!V_pbomRow.IszzdifficultyNull())
               {
                   pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
               }
               else { pbomRow.zzdifficulty = ""; }
               if (!V_pbomRow.IszzmachineqtyNull())
               {
                   pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
               }
               else { pbomRow.zzmachineqty = ""; }
               if (!V_pbomRow.IszzproduceqtyNull())
               {
                   pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
               }
               else { pbomRow.zzproduceqty = ""; }
               if (!V_pbomRow.IszzproductionNull())
               {
                   pbomRow.zzproduction = V_pbomRow.zzproduction;
               }
               else { pbomRow.zzproduction = ""; }
               if (!pbomRow.IszzrequestNull())
               {
                   pbomRow.zzrequest = V_pbomRow.zzrequest;
               }
               else { pbomRow.zzrequest = ""; }
               if (!V_pbomRow.IszzspeedNull())
               {
                   pbomRow.zzspeed = V_pbomRow.zzspeed;
               }
               else { pbomRow.zzspeed = ""; }
               if (!V_pbomRow.IszzyujiproductionNull())
               {
                   pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
               }
               else { pbomRow.zzyujiproduction = ""; }
               if (!V_pbomRow.IszzzwDensityNull())
               {
                   pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
               }
               else { pbomRow.zzzwDensity = ""; }
               if (!V_pbomRow.IszzzwjgtxNull())
               {
                   pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
               }
               else { pbomRow.zzzwjgtx = ""; }
               pbomTable.AddpbomTable1Row (pbomRow);

           }
           ds.Tables.Add(pbomTable);
          // r.Load(@"E:\东华软件项目\报表\pbomasterzhenzhi.frx");
           r.Load(@"\\192.168.0.27\东华软件\报表\pbomasterzhenzhi.frx");
           r.RegisterData(ds);
         // r.Design();
          r.Show();
        }
        //datagridview第一列显示行号
        private void dGridPbomMaster_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            baseSet.datGridSet.gridViesSet.setGridViewRowNum(e, dGridPbomMaster);
        }

        private void 梳织打印小ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            //  DataSetPrint.pbomTableDataTable pbomTable = new DataSetPrint.pbomTableDataTable();
            //  DataSetPrint.pbomDtailTableDataTable pbomDtailTable = new DataSetPrint.pbomDtailTableDataTable();
            //  DataSetPrint.pbomMarkDataTable pbomMarkTable = new DataSetPrint.pbomMarkDataTable();
            //  DataSetPrint.materialListTableDataTable materialListTable= new DataSetPrint.materialListTableDataTable();
            //  //string matNum = dGridPbomMaster.CurrentRow.Cells["matNum"].Value.ToString();
            //string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            //orderDataSet.pbomDetailDataTable pbomDetailTable = pbomDetail.getpbomDetailbypanmeAll(pname);
            //orderDataSet.pbomMarkDataTable pbomMarkTable2 = pbomMark.getpbomMarkAllBypname(pname);
            //orderDataSet.pbomMasterDataTable pbomMasterTable = pbomMaster.getpbomMasterAllBypname(pname);
            //orderDataSet.materialListDataTable material = materilList.getmaterialListAll  () ;

            #region 旧代码          foreach (orderDataSet.pbomMasterRow pbomMasterRow in pbomMasterTable)

            #endregion          }



            Report r = new Report();
            DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            //dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable = pbomMaster.getV_pboMasterAllBypname(pname);
            DataSetPrint.pbomTable1DataTable pbomTable = new DataSetPrint.pbomTable1DataTable();
            foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
            {
                DataSetPrint.pbomTable1Row pbomRow = pbomTable.NewpbomTable1Row();
                if (!V_pbomRow.IsmatSpecNull())
                {
                    pbomRow.matSpec = V_pbomRow.matSpec;
                }
                else { pbomRow.matSpec = ""; }
                if (!V_pbomRow.IsmatNameNull())
                {
                    pbomRow.matName = V_pbomRow.matName;
                }
                else { pbomRow.matName = ""; }
                pbomRow.pname = V_pbomRow.pname;
                if (!V_pbomRow.IscustNumNull())
                {
                    pbomRow.custNum = V_pbomRow.custNum;
                }
                else { pbomRow.custNum = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
                else { pbomRow.bweight = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
                else { pbomRow.awgight = ""; }
                pbomRow.createDate = V_pbomRow.createDate.ToString();
                if (!pbomRow.IscreateUserNull())
                {
                    pbomRow.createUser = pbomRow.createUser;
                }
                else { pbomRow.createUser = ""; }
                if (!V_pbomRow.IswbNull())
                {
                    pbomRow.wb = V_pbomRow.wb;
                }
                else { pbomRow.wb = ""; }
                if (V_pbomRow.matNum != "0")
                {
                    pbomRow.matNum = V_pbomRow.matNum;
                }
                else { pbomRow.matNum = ""; }
                if (!V_pbomRow.IsptNull())
                {
                    pbomRow.pt = V_pbomRow.pt;
                }
                else { pbomRow.pt = ""; }
                if (!V_pbomRow.IspzNull())
                {
                    pbomRow.pz = V_pbomRow.pz;
                }
                else { pbomRow.pz = ""; }
                if (!V_pbomRow.IscustNameNull())
                {
                    pbomRow.custName = V_pbomRow.custName;
                }
                else { pbomRow.custName = ""; }
                if (V_pbomRow.alen != 0)
                {
                    pbomRow.alen = V_pbomRow.alen.ToString();
                }
                else { pbomRow.alen = ""; }
                pbomRow.aweight = V_pbomRow.aweight.ToString();
                if (V_pbomRow.ts != 0)
                {
                    pbomRow.ts = V_pbomRow.ts.ToString();
                }
                else { pbomRow.ts = ""; }
                if (V_pbomRow.blen != 0)
                {
                    pbomRow.blen = V_pbomRow.blen.ToString();
                }
                else { pbomRow.blen = ""; }
                if (V_pbomRow.aweight != 0)
                {
                    pbomRow.aweight = V_pbomRow.aweight.ToString();
                }
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.pweight != 0)
                {
                    pbomRow.pweight = V_pbomRow.pweight.ToString();
                }
                else { pbomRow.pweight = ""; }
                if (!pbomRow.IsmarkNull())
                {
                    pbomRow.mark = V_pbomRow.mark;
                }
                else { pbomRow.mark = ""; }
                if (!V_pbomRow.IsrequestNull())
                {
                    pbomRow.request = V_pbomRow.request;
                }
                else { pbomRow.request = ""; }
                if (!V_pbomRow.IsdifficultyNull())
                {
                    pbomRow.difficulty = V_pbomRow.difficulty;
                }
                else { pbomRow.difficulty = ""; }
                if (!V_pbomRow.IsendopenNull())
                {
                    pbomRow.endopen = V_pbomRow.endopen;
                }
                else { pbomRow.endopen = ""; }
                if (!V_pbomRow.IsendshrinkNull())
                {
                    pbomRow.endshrink = V_pbomRow.endshrink;
                }
                else { pbomRow.endshrink = ""; }
                if (!V_pbomRow.IsgqDensityNull())
                {
                    pbomRow.gqDensity = V_pbomRow.gqDensity;
                }
                else { pbomRow.gqDensity = ""; }
                if (!V_pbomRow.IsmethodsNull())
                {
                    pbomRow.methods = V_pbomRow.methods;
                }
                else { pbomRow.methods = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberKf = V_pbomRow.numberKf;
                }
                else { pbomRow.numberKf = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberNf = V_pbomRow.numberNf;
                }
                else { pbomRow.numberNf = ""; }

                if (!V_pbomRow.IsproductionKfNull())
                {
                    pbomRow.productionKf = V_pbomRow.productionKf;
                }
                else { pbomRow.productionKf = 0; }
                if (!V_pbomRow.IsproductionNfNull())
                {
                    pbomRow.productionNf = V_pbomRow.productionNf;
                }
                else { pbomRow.productionNf = 0; }
                if (!V_pbomRow.IsspeedKfNull())
                {
                    pbomRow.speedKf = V_pbomRow.speedKf;
                }
                else { pbomRow.speedKf = ""; }
                if (!V_pbomRow.IsspeedNfNull())
                {
                    pbomRow.speedNf = V_pbomRow.speedNf;
                }
                else { pbomRow.speedNf = ""; }
                if (!V_pbomRow.IsstartopenNull())
                {
                    pbomRow.startopen = V_pbomRow.startopen;
                }
                else { pbomRow.startopen = ""; }
                if (!V_pbomRow.IsstartshrinkNull())
                {
                    pbomRow.startshrink = V_pbomRow.startshrink;
                }
                else { pbomRow.startshrink = ""; }
                if (!V_pbomRow.IsstartwidthNull())
                {
                    pbomRow.startwidth = V_pbomRow.startwidth;
                }
                else { pbomRow.startwidth = ""; }
                if (!V_pbomRow.IsendwidthNull())
                {
                    pbomRow.endwidth = V_pbomRow.endwidth;
                }
                else { pbomRow.endwidth = ""; }
                if (!V_pbomRow.IstwoLengthNull())
                {
                    pbomRow.twoLength = V_pbomRow.twoLength;
                }
                else { pbomRow.twoLength = ""; }
                if (!V_pbomRow.IszwDensityNull())
                {
                    pbomRow.zwDensity = V_pbomRow.zwDensity;
                }
                else { pbomRow.zwDensity = ""; }
                if (!V_pbomRow.IszzbasicspecNull())
                {
                    pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
                }
                else { pbomRow.zzbasicspec = ""; }
                if (!V_pbomRow.IszzdifficultyNull())
                {
                    pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
                }
                else { pbomRow.zzdifficulty = ""; }
                if (!V_pbomRow.IszzmachineqtyNull())
                {
                    pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
                }
                else { pbomRow.zzmachineqty = ""; }
                if (!V_pbomRow.IszzproduceqtyNull())
                {
                    pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
                }
                else { pbomRow.zzproduceqty = ""; }
                if (!V_pbomRow.IszzproductionNull())
                {
                    pbomRow.zzproduction = V_pbomRow.zzproduction;
                }
                else { pbomRow.zzproduction = ""; }
                if (!pbomRow.IszzrequestNull())
                {
                    pbomRow.zzrequest = V_pbomRow.zzrequest;
                }
                else { pbomRow.zzrequest = ""; }
                if (!V_pbomRow.IszzspeedNull())
                {
                    pbomRow.zzspeed = V_pbomRow.zzspeed;
                }
                else { pbomRow.zzspeed = ""; }
                if (!V_pbomRow.IszzyujiproductionNull())
                {
                    pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
                }
                else { pbomRow.zzyujiproduction = ""; }
                if (!V_pbomRow.IszzzwDensityNull())
                {
                    pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
                }
                else { pbomRow.zzzwDensity = ""; }
                if (!V_pbomRow.IszzzwjgtxNull())
                {
                    pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
                }
                else { pbomRow.zzzwjgtx = ""; }
                pbomTable.AddpbomTable1Row(pbomRow);

            }
            //ds.Tables.Add (pbomTable);
            //ds.Tables.Add(pbomDtailTable);
            //ds.Tables.Add(pbomMarkTable);
            ds.Tables.Add(pbomTable);
            //r.Load(@"E:\东华软件项目\报表\pbomaster.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\pbomasterxiao.frx");
            r.RegisterData(ds);
            r.Show();
            // r.Design();
        }
    }
}
